#include <studyinfo.h>
#include <ui_studyinfo.h>
#include <gdcmStringFilter.h>
StudyInfo::StudyInfo(QWidget *parent) :
  QWidget(parent),
  ui(new Ui::StudyInfo) {
  ui->setupUi(this);
}

StudyInfo::~StudyInfo() {
  delete ui;
}

bool StudyInfo::Open(const gdcm::File & file) {
  //  std::cout << "FILE = " << file << std::endl;
    const gdcm::DataSet & ds = file.GetDataSet();
//    std::cout << "DATASET: \n" << ds << std::endl;
//    const gdcm::FileMetaInformation & header= file.GetHeader();
//    std::cout << "HEADER: \n" << header << std::endl;
  gdcm::StringFilter sf;
  sf.SetFile(file);
  ui->lineEdit->setText  ( QString::fromStdString(sf.ToString(gdcm::Tag(0x10,0x10)) ));
  ui->lineEdit_2->setText( QString::fromStdString(sf.ToString(gdcm::Tag(0x08,0x90)) ));
  ui->lineEdit_3->setText( QString::fromStdString(sf.ToString(gdcm::Tag(0x0032,0x1033)) ));
  if( ds.FindDataElement(gdcm::Tag(0x0032,0x1032))) {
    const gdcm::DataElement &de = ds.GetDataElement( gdcm::Tag(0x0032,0x1032) );
    std::cout << "DATAELEMENT: " << de.GetValue() << std::endl;
    //      ui->lineEdit->setText(de.GetByteValue());
  }
  return true;
}
